package com.yn.system.util;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.yn.system.service.SeqnumService;

/**
 * 通用编号生成工具类
 * 
 *
 */
@Component  
public class CodeGeneratorUtil {
	@Autowired
	private SeqnumService seqnumService;
	private static CodeGeneratorUtil codeGeneratorUtil;
	
	public void setSeqnumService(SeqnumService seqnumService) {
		this.seqnumService = seqnumService;
	}
	
	@PostConstruct  
    public void init() {  
		codeGeneratorUtil=this;
		codeGeneratorUtil.seqnumService=this.seqnumService;
	}
	/**
	 * 获取系统编号
	 * @param orgId
	 * @param projectId
	 * @param tableName
	 * @param colName
	 * @return
	 * @throws Exception
	 */
	public static String getSeqNum(String tableName,String colName){
	    return codeGeneratorUtil.seqnumService.generateSystemCode(tableName, colName);
	}
}
